package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @author wfyn
 * @date 2023/10/6
 */

public interface OrderMapper {


    /**
     * 插入订单数据
     * @param orders
     */
    Integer insert (Orders orders);

    /**
     * 根据订单号查询订单
     * @param orderNumber
     */
    @Select("select * from orders where number = #{orderNumber}")
    Orders getByNumber(String orderNumber);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    /**
     * 根据状态和订单时间查询订单
     * @param status
     * @param orderTime
     * @return
     */

    @Select("select * from orders where status = #{status} and order_time < #{orderTime}")
    List<Orders> getByStatusAndOrderTimeLT(Integer status, LocalDateTime orderTime);


    @Select("select * from orders where id = #{id}")
    Orders getById(String id);


    Page<OrderVO> pageList(OrdersPageQueryDTO ordersPageQueryDTO);

    Double sumByMap(Map map);

    OrderStatisticsVO statistics();

    Integer countByMap(Map map);

    List<GoodsSalesDTO> getSalesTop10(LocalDateTime begin, LocalDateTime end);


    Integer getSaleByDishId(Long dishId);

    Integer getSaleBySetmealId(Long id);
}
